<?php
/*
 * @Author: CHINAKAIYUAN<sunkaiyuan@namenode.cn>
 * @Date: 2022-02-03 00:33:05
 * @LastEditTime: 2023-09-19 15:41:44
 * @LastEditors: 孙开源 && sunkaiyuan@namenode.cn
 * @Description: 品质管理异常
 */

namespace App\Models;

use App\Traits\AutoCodeTrait;
use App\Traits\CommonUserTrait;
use App\Traits\MaterialTrait;
use Illuminate\Support\Facades\App;

class QaAbnormal extends BaseModel
    {
    use MaterialTrait;
    use CommonUserTrait;
    use AutoCodeTrait;
    public $timestamps = true;
    public $table = "sys_qa_abnormal";
    protected $guarded = [];
    //附件
    public $attachmentkey = "code";
    protected $casts = [];

    /**
     * 标识
     *
     * @var string
     */
    protected $ACSign = 'QAABNORMAL_CODE';

    /**
     * 编号所用的字段
     *
     * @var string
     */
    protected $ACCode = 'code';

    public function status()
        {
        return $this->belongsTo(Dic::class, "status_id", "key")->where(function ($q)
            {
            $q->where("code", 'Finance_Status');
            });
        }

    public function message()
        {
        return $this->hasMany(QaAbnormalMessage::class, "abnormal_id");
        }
    public function pro_pot()
        {
        return $this->belongsTo(ProPot::class, "dyelot", "dyelot");
        }
    }
